<template>
  <div>
    <navbar-app></navbar-app>
    <div class="content-in">
      <div v-for="item in list" :key="item.id" class="row">
        <img src="@/assets/images/work/joinus-01.png" alt="" />
        <p class="blue ft-bold tx-center">{{ item[`job${capitalizeLang}`] }}</p>
        <p class="tx-center ft-24">{{ item[`companyName${capitalizeLang}`] }}</p>
        <p class="mg-t-24 ft-24">
          · {{ $t('work.joinus.department') }}：{{ item[`department${capitalizeLang}`] }} <br />
          · {{ $t('work.joinus.post') }}：{{ item[`job${capitalizeLang}`] }}<br />
          · {{ $t('work.joinus.addres') }}：{{ item[`place${capitalizeLang}`] }} <br />
          · {{ $t('work.joinus.experience') }}：{{ item[`experience${capitalizeLang}`] }}<br />
        </p>
        <div class="detail active ft-24">
          <span class="flex-shrink">· {{ $t('work.joinus.qualifications') }}：</span>
          <p v-for="dItem in item.duties" :key="dItem.id">
            {{ dItem[`description${capitalizeLang}`] }}
          </p>
        </div>
        <div class="detail ft-24" :class="{ active: active[item.id] }">
          <span class="flex-shrink">· {{ $t('work.joinus.benefits') }}：</span>
          <p v-for="dItem in item.duties" :key="dItem.id">
            {{ dItem[`description${capitalizeLang}`] }}
          </p>
        </div>
        <div class="detail ft-24" :class="{ active: active[item.id] }">
          <span class="flex-shrink">· {{ $t('work.joinus.duties') }}：</span>
          <p v-for="duItem in item.duties" :key="duItem.id">
            {{ duItem[`description${capitalizeLang}`] }}
          </p>
        </div>
        <p class="mg-t-24 ft-24 grey">{{ $t('work.joinus.deadline') }}：{{ item.applyEndTime }}</p>
        <p class="ft-24 grey">{{ $t('work.joinus.releaseTime') }} : {{ item.createTime }}</p>
        <div v-if="active[item.id]" class="contact" @click="toContactUs">
          {{ $t('common.contact') }}
        </div>
        <i
          :class="active[item.id] ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
          class="icon-arrow"
          @click="more(item.id)"
        ></i>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
import NavbarApp from '../navbar_app'

export default {
  components: {
    NavbarApp,
  },
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      active: {},
    }
  },
  computed: {
    ...mapState(['lang']),
    ...mapGetters(['capitalizeLang']),
  },
  methods: {
    more(id) {
      this.$set(this.active, id, !this.active[id])
    },
    async toContactUs() {
      this.$router.push({
        path: '/contact-us',
      })
    },
  },
}
</script>

<style lang="less" scoped>
.content-in {
  padding: 24px;
}

.row {
  box-shadow: 0 3px 7px 0 rgba(35, 24, 21, 0.11);
  background: #fff;
  padding: 40px 24px 50px 24px;
  margin-bottom: 20px;

  img {
    width: 110px;
    height: 110px;
    margin: 0 auto 30px auto;
    display: block;
  }

  .mg-t-24 {
    margin-top: 24px;
  }

  .detail {
    margin-bottom: 8px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s linear;

    &.active {
      max-height: 2000px;
    }

    p {
      padding-left: 12px;
    }
  }

  .contact {
    width: 300px;
    padding: 10px 20px;
    text-align: center;
    color: #fff;
    cursor: pointer;
    background-color: #0261bc;
    border-radius: 10px;
    margin: 30px auto 0 auto;
  }

  .icon-arrow {
    font-size: 32px;
    margin: 30px auto 0 auto;
    display: block;
    width: 80px;
    text-align: center;
  }
}
</style>
